﻿function FillData(){
    var xmlDoc = LoadXML("Data/new-project.xml");
   
    var x = xmlDoc.getElementsByTagName("project");
    if(x.length > 0){
        var topDiv = document.getElementById("accordion");
        //clear div
        var clrDiv = document.createElement("div");
        clrDiv.className = "clear";    
                     
        for(var i=0; i<x.length; i++){                   

            //name
            var name = document.createElement("a");
            name.setAttribute("href","javascript:void(0)");
            name.innerHTML = x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue;
            
            //date
            var date = document.createElement("span");
            date.innerHTML = x[i].getElementsByTagName("date")[0].childNodes[0].nodeValue;
            
            //name and date wrapper
            var ph = document.createElement("p");
            ph.appendChild(name);
            ph.appendChild(document.createElement("br"));
            ph.appendChild(date);
            
            //tabhead
            var tabhead = document.createElement("div");
            tabhead.className = "tabhead_single";
            tabhead.setAttribute("role","tab");
            tabhead.appendChild(ph);
            clrDiv = document.createElement("div");
            clrDiv.className = "clear";
            tabhead.appendChild(clrDiv);
    
            
            //image
            var image = document.createElement("img");         
            image.src = x[i].getElementsByTagName("image")[0].childNodes[0].nodeValue;                              
                                
            //image preview
            var imgPreview = document.createElement("a");  
            imgPreview.setAttribute("href",x[i].getElementsByTagName("imagePreview")[0].childNodes[0].nodeValue);
            imgPreview.className = "preview";
            imgPreview.appendChild(image);  

                                                 
            //infoWrapper
            var infoWrapper = document.createElement("ul");

            
            //location info
            var locInfo = document.createElement("span");
            locInfo.innerHTML = x[i].getElementsByTagName("location")[0].childNodes[0].nodeValue;
                                  
            //location
            var loc = document.createElement("li");
            loc.innerHTML = "Địa điểm: ";
            loc.appendChild(locInfo);
            infoWrapper.appendChild(loc);

            //sizeInfo info
            var sizeInfo = document.createElement("span");
            sizeInfo.innerHTML = x[i].getElementsByTagName("size")[0].childNodes[0].nodeValue;
                                  
            //size
            var size = document.createElement("li");
            size.innerHTML = "Quy mô: ";
            size.appendChild(sizeInfo);
            infoWrapper.appendChild(size); 
            

            //boss info
            var bossInfo = document.createElement("span");
            bossInfo.innerHTML = x[i].getElementsByTagName("boss")[0].childNodes[0].nodeValue;
                                
            //boss
            var boss = document.createElement("li");
            boss.innerHTML = "Chủ đầu tư: ";
            boss.appendChild(bossInfo);
            infoWrapper.appendChild(boss);
            
            //startdate info
            var startDateInfo  = document.createElement("span");
            startDateInfo.innerText = date.innerHTML;
            
            //startdate
            var startDate  = document.createElement("li");
            startDate.innerHTML = "Ngày kí hợp đồng: ";
            startDate.appendChild(startDateInfo);
            infoWrapper.appendChild(startDate);
                                   
            //tabpanel
            var tabpanel = document.createElement("div");
            tabpanel.className = "tabpanel_splitted";
            tabpanel.setAttribute("role","tabpanel");
            tabpanel.appendChild(imgPreview);
            tabpanel.appendChild(infoWrapper);
            clrDiv = document.createElement("div");
            clrDiv.className = "clear";
            tabpanel.appendChild(clrDiv);

            
            topDiv.appendChild(tabhead);
            topDiv.appendChild(tabpanel);
            
            
        }
        topDiv.appendChild(clrDiv);
    }
}